Update dapp skill to JS SDK v16 (contract.Client, Node 22, pollTransaction)#43
Conversation
….Client Re-grounds the SDK-mechanics sections against the official JS SDK docs (stellar.github.io/js-stellar-sdk): - Node 20+ -> Node 22+; note stellar-base folded into stellar-sdk, ESM-first, native fetch (v16 migration). - Lead smart contract invocation with the typed contract.Client (Client.from<T> -> method() -> signAndSend); demote the low-level Contract.call path to an advanced note using prepareTransaction. - Replace the unbounded getTransaction poll loop with rpc.pollTransaction. - Add rpc.queryContract / getContractMethods one-liners for reading contract state; keep manual getLedgerEntries as advanced. - Use the typed NotFoundError in the balance example and point to result codes for submission failures. - Add a sourcing note: SDK mechanics track the JS SDK docs; wallet, passkey, and relayer sections are separate packages verified against their own docs.
There was a problem hiding this comment.
Pull request overview
Updates the skill documentation set (primarily the dapp skill) to align Soroban/JS client patterns with @stellar/stellar-sdk v16 guidance, while also incorporating stacked documentation hygiene fixes (e.g., deduping standards references and correcting copy/paste snippet issues).
Changes:
- Refreshes
dappSDK mechanics to v16 patterns: Node 22 requirement notes,contract.Client-first invocation,prepareTransactionfor low-level paths, andrpc.pollTransactionfor bounded polling. - Fixes/modernizes copy-paste examples across skills (e.g., lazy per-network config factories, missing imports in Rust examples).
- Deduplicates/condenses large reference sections in
standardsto point to canonical guides.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| skills/standards/SKILL.md | Replaces long inlined security/tools/ecosystem catalogs with pointers and compact link lists to reduce drift. |
| skills/smart-contracts/testing.md | Adds missing IntoVal import so the auth-mocking example compiles when copied. |
| skills/smart-contracts/development.md | Adds missing symbol_short / vec imports so the data-types example compiles when copied. |
| skills/data/SKILL.md | Makes network config resolution lazy and adds an explicit unknown-network guard. |
| skills/dapp/SKILL.md | Updates SDK v16 guidance and examples (Node 22+, contract.Client, bounded polling, typed error note, read helpers). |
| skills/assets/SKILL.md | Replaces placeholder SEP snippets with accurate prose summaries + spec links. |
| skills/agentic-payments/SKILL.md | Minor wording update in troubleshooting guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| horizonUrl: "https://horizon-testnet.stellar.org", | ||
| rpcUrl: "https://soroban-testnet.stellar.org", | ||
| networkPassphrase: StellarSdk.Networks.TESTNET, | ||
| friendbotUrl: "https://friendbot.stellar.org" as string | null, | ||
| }; |
| The canonical way to call a Soroban contract from JS is the `contract.Client`, not hand-built `Contract.call` + `assembleTransaction`. The client reads the contract's interface from the network, so each method is callable by name and returns an `AssembledTransaction`. You get a native JS result and don't build ScVals by hand. | ||
|
|
||
| ```typescript | ||
| import { contract, rpc, Networks } from "@stellar/stellar-sdk"; |
| export async function getCounterClient( | ||
| contractId: string, | ||
| publicKey: string, | ||
| signTransaction: contract.ClientOptions["signTransaction"], | ||
| ) { | ||
| return contract.Client.from<CounterContract>({ | ||
| contractId, | ||
| rpcUrl: "https://soroban-testnet.stellar.org", | ||
| networkPassphrase: Networks.TESTNET, | ||
| publicKey, | ||
| signTransaction, | ||
| }); | ||
| } |
| const transaction = new StellarSdk.TransactionBuilder(account, { | ||
| fee: StellarSdk.BASE_FEE, | ||
| networkPassphrase: config.networkPassphrase, | ||
| }) |
| > For submission failures, Horizon returns result codes under `error.response?.data?.extras?.result_codes` (`transaction` + per-`operation`). See [Handle Errors](https://stellar.github.io/js-stellar-sdk/guides/05-handle-errors). | ||
|
|
There was a problem hiding this comment.
This will be getting fixed in the next release to a simpler API
Drops the unused rpc/Networks imports and the hardcoded testnet URL; the example now follows the lib/stellar.ts pattern used elsewhere in this doc, so it copies correctly into non-testnet setups.
|
Pushed two small commits after #41 landed: a merge of main to bring the branch current, and a fix for the two Copilot comments that still applied — the contract.Client example had unused |
What
Re-grounds the SDK-mechanics sections of the
dappskill against the official JS SDK docs (v16), which now publishllms.txt/llms-full.txtbundles for AI tools. Several patterns in the skill had drifted from what the docs treat as canonical.Changes
engines: >=22.0.0). Added notes that@stellar/stellar-baseis folded into@stellar/stellar-sdk, the SDK is ESM-first, and it uses nativefetch.contract.Client. The docs' canonical "Invoke a Contract" guide usesClient.from<T>()→method()→signAndSend(), and callsAssembledTransactionthe "main workhorse." The skill only showed the low-levelContract.call+assembleTransactionpath. Now the typed client is primary; the low-level path is kept as an advanced note (usingprepareTransaction).while (status === "NOT_FOUND")loop withrpc.pollTransaction.rpc.queryContract/rpc.getContractMethods; kept manualgetLedgerEntriesas an advanced fallback.NotFoundErrorinstead oferror.response?.status === 404, and points to Horizon result codes for submission failures.Why
Skills are consumed by AI agents that copy examples verbatim. The old contract-invocation and polling patterns still compile but are lower-level than the docs recommend, and the Node version was factually wrong.
Notes for reviewers
fix/skill-audit-example-code-and-dedup(PR Fix example code bugs, stale link labels, and duplicated reference content #41), which also editsdapp/SKILL.mdand hasn't merged yet. Until Fix example code bugs, stale link labels, and duplicated reference content #41 merges, this PR's diff includes Fix example code bugs, stale link labels, and duplicated reference content #41's commits. Merge Fix example code bugs, stale link labels, and duplicated reference content #41 first, then this narrows to just the dapp SDK update.